package view.user;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import controller.KeyHandler;
import controller.SlideHandler;
import controller.ActionEvents.ActionHandler;

import javax.swing.JSlider;
import javax.swing.JButton;
import javax.swing.JPasswordField;

/**
 * @author Christian
 * Class About.java contains information about the program.
 */
public class Settings extends JPanel 
{

	/**
	 * Declares the variables used in the GUI.
	 */
	private JLabel lblSettings;
	private ActionHandler actionHandler;
	private JSlider slider;
	private JLabel lblThemeChooser;
	private JPasswordField passwordFieldOldPw;
	private JPasswordField passwordFieldNewPw;
	private JPasswordField passwordFieldConfirmPw;
	private JLabel lblOldPassword;
	private JLabel lblNewPassword;
	private JLabel lblConfirm;
	private JButton btnSubmitPasswordChange;
	private SlideHandler slideHandler;
	private JLabel lblSetPasswordStrength;
	private JLabel lblPasswordStrength;
	private KeyHandler keyHandler;
	private JButton btnGoesGreenSkin;
	private JButton btnClassicSkin;
	
	
	
	
	/**
	 * Constructor creates the JPanel with CardLayout.
	 * @see Layout managers, CardLayout.
	 * Components is also here specified.
	 */
	public Settings(ActionHandler actionHandler, SlideHandler slideHandler, KeyHandler keyHandler) 
	{
		this.actionHandler = actionHandler;
		this.slideHandler = slideHandler;
		this.keyHandler = keyHandler;
		setLayout(null);
		setPreferredSize(new Dimension(750, 372));
		setBackground(Color.decode("#56606a"));
		
		
	   
		
		lblSettings = new JLabel("Settings");
		lblSettings.setFont(new Font("Euphemia UCAS", Font.PLAIN, 28));
		lblSettings.setBounds(322, 6, 163, 39);
		add(lblSettings);	
		
		slider = new JSlider();
		slider.setBounds(239, 94, 268, 39);
		slider.addChangeListener(slideHandler);
		slider.setMaximum(100);
		slider.setMinimum(0);
		add(slider);
		
		lblThemeChooser = new JLabel("Theme chooser");
		lblThemeChooser.setBounds(311, 66, 114, 16);
		add(lblThemeChooser);
		
		passwordFieldOldPw = new JPasswordField();
		passwordFieldOldPw.setBounds(259, 180, 233, 28);
		add(passwordFieldOldPw);
		
		passwordFieldNewPw = new JPasswordField();
		passwordFieldNewPw.setBounds(259, 234, 233, 28);
		passwordFieldNewPw.addKeyListener(keyHandler);
		add(passwordFieldNewPw);
		
		passwordFieldConfirmPw = new JPasswordField();
		passwordFieldConfirmPw.setBounds(257, 266, 235, 28);
		add(passwordFieldConfirmPw);
		
		
		lblOldPassword = new JLabel("Old password");
		lblOldPassword.setBounds(124, 186, 114, 16);
		add(lblOldPassword);
		
		lblNewPassword = new JLabel("New password");
		lblNewPassword.setBounds(118, 240, 120, 22);
		add(lblNewPassword);
		
		lblConfirm = new JLabel("Confirm");
		lblConfirm.setBounds(124, 272, 114, 22);
		add(lblConfirm);
		
		btnSubmitPasswordChange = new JButton("");
		btnSubmitPasswordChange.setIcon(new ImageIcon(Settings.class.getResource("/Pictures/ux/submit.png")));
		btnSubmitPasswordChange.setBounds(305, 319, 130, 29);
		add(btnSubmitPasswordChange);
		btnSubmitPasswordChange.addActionListener(actionHandler);
		btnSubmitPasswordChange.setBorderPainted(false);
		btnSubmitPasswordChange.setContentAreaFilled(false);
		btnSubmitPasswordChange.setActionCommand("SubmitPasswordChange");
		
		lblSetPasswordStrength = new JLabel("");
		lblSetPasswordStrength.setBounds(381, 291, 99, 16);
		add(lblSetPasswordStrength);
		
		lblPasswordStrength = new JLabel("Password Strength: ");
		lblPasswordStrength.setBounds(259, 291, 130, 16);
		add(lblPasswordStrength);
		
		btnGoesGreenSkin = new JButton("Goes Green Skin");
		btnGoesGreenSkin.setBounds(192, 145, 163, 29);
		btnGoesGreenSkin.addActionListener(actionHandler);
		btnGoesGreenSkin.setActionCommand("changeSkinGreen");
		add(btnGoesGreenSkin);
		
		btnClassicSkin = new JButton("Classic skin");
		btnClassicSkin.setBounds(367, 145, 163, 29);
		btnClassicSkin.addActionListener(actionHandler);
		btnClassicSkin.setActionCommand("changeSkinClassic");
		add(btnClassicSkin);
	
		
	    
		
	}
	
	
	/**
	 * @return the btnSubmitPasswordChange
	 */
	public JButton getBtnSubmitPasswordChange() {
		return btnSubmitPasswordChange;
	}


	/**
	 * @return the passwordFieldOldPw
	 */
	public JPasswordField getPasswordFieldOldPw() {
		return passwordFieldOldPw;
	}

	/**
	 * @param passwordFieldOldPw the passwordFieldOldPw to set
	 */
	public void setPasswordFieldOldPw(JPasswordField passwordFieldOldPw) {
		this.passwordFieldOldPw = passwordFieldOldPw;
	}

	/**
	 * @return the passwordFieldNewPw
	 */
	public JPasswordField getPasswordFieldNewPw() {
		return passwordFieldNewPw;
	}

	/**
	 * @param passwordFieldNewPw the passwordFieldNewPw to set
	 */
	public void setPasswordFieldNewPw(JPasswordField passwordFieldNewPw) {
		this.passwordFieldNewPw = passwordFieldNewPw;
	}

	/**
	 * @return the passwordFieldConfirmPw
	 */
	public JPasswordField getPasswordFieldConfirmPw() {
		return passwordFieldConfirmPw;
	}

	/**
	 * @param passwordFieldConfirmPw the passwordFieldConfirmPw to set
	 */
	public void setPasswordFieldConfirmPw(JPasswordField passwordFieldConfirmPw) {
		this.passwordFieldConfirmPw = passwordFieldConfirmPw;
	}

	/**
	 * @return the slider
	 */
	public JSlider getSlider() {
		return slider;
	}

	/**
	 * @param slider the slider to set
	 */
	public void setSlider(JSlider slider) {
		this.slider = slider;
	}

	/**
	 * @return the lblSetPasswordStrength
	 */
	public JLabel getLblSetPasswordStrength() {
		return lblSetPasswordStrength;
	}
}
